﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.MT3DMS.DomainLayer
{
    [Serializable]
   public class MTStressPeriodCollecion
    {


        public MTStressPeriodCollecion()
        {

            _periods=new List<MTStressPeriod> ();
        }

        [field:NonSerialized]
        public event EventHandler StressPeriodChanged;


        List<MTStressPeriod> _periods;

        public List<MTStressPeriod> Periods
        {
            get { return _periods; }
          
        }



        /// <summary>
        /// 这里用于表示是否需要更新外部相关的SP数据
        /// </summary>
        /// <param name="periods"></param>
        /// <returns></returns>
        protected bool IsSPChanged(List<MTStressPeriod> periods)
        {
            if (periods.Count != this._periods.Count)
            {
                return true;

            }
            else
            {
                return false; 
                
            }
 
        }

        public void ResetPeriods(List<MTStressPeriod> periods,bool isForEvent = false)
        {
            
            bool isNeedUpdate=this.IsSPChanged(periods);
            if (!isForEvent)
            {
                this._periods.Clear();
                this._periods.AddRange(periods);

            }
            if (isNeedUpdate||isForEvent)
            {

                if (StressPeriodChanged != null)
                {
                    StressPeriodChanged(this, new EventArgs());

                }
                
            }


         




 
        }


    }
}
